<script setup lang="ts">
import { computed } from 'vue';
import { TableActionItems } from './types';

const props = withDefaults(defineProps<{ linkMode: boolean, callParams?: any, metaInfo?: TableActionItems }>(), {
  callParams: () => ({}),
})
const LinkProps = computed(() => {
  const { icon, type } = props?.metaInfo || {}
  return { icon, type }
})
function handleClick() {
  props?.metaInfo?.call(props.callParams)
}
</script>
<template>
  <ElLink v-if="linkMode" v-bind="LinkProps" @click="handleClick">
    <slot />
  </ElLink>
  <ElButton v-bind="LinkProps" :text="metaInfo?.textmode" @click="handleClick" v-else>
    <slot />
  </ElButton>
</template>